package com.strategy.core;


import lombok.Setter;
import com.strategy.annotation.Strategy;

/**
 * 策略抽象类，提供基础实现
 */
@Setter
public abstract class AbstractStrategy<T, P, R> implements BaseStrategy<T, P, R> {

    private String key;
    private String version;
    private String description;

    public AbstractStrategy() {
        // 从注解中获取策略信息
        Strategy strategyAnnotation = this.getClass().getAnnotation(Strategy.class);
        if (strategyAnnotation != null) {
            this.key = strategyAnnotation.key();
            this.version = strategyAnnotation.version();
            this.description = strategyAnnotation.description();
        }
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public String getVersion() {
        return version;
    }

    @Override
    public String getDescription() {
        return description;
    }

}
